pimpas.AJAX.Populate.Select = Class.create( );
pimpas.Extends(pimpas.AJAX.Populate.Select.prototype, pimpas.AJAX.Populate.Object.prototype);
pimpas.Extends(pimpas.AJAX.Populate.Select.prototype,
   {
	   populate: function(xmlObject, xmlElement) {
		    this.log.log(pimpas.Log.INFO, 'Executing Select Populate... Object: '+this.id);
			
			var entries = xmlObject.eval( new pimpas.XML.Xpath( '//option' ) );
			var id = xmlObject.getAsText( xmlObject.eval( new pimpas.XML.Xpath( 'id' ), xmlElement).iterateNext( ) );
			if(!pimpas.DOM.isSelect(id)) {
				this.log.log(pimpas.Log.ERROR, 	'The Object with ID ['+this.id+'] ITS NOT SELECT!!!!');
				return;
			}
			
			var entry = null;
			var label = null;
			var value = null;
			var selected = null;
			pimpas.DOM.clearAllOptions( id );
			while((entry=entries.iterateNext())!=null) {
				label = xmlObject.getAsText( entry );
				value = xmlObject.getAttributeValue( entry, 'value' );
				selected = xmlObject.getAttributeValue( entry, 'selected' );
				pimpas.DOM.addOption( id, label, value );
				if(selected == 'true' || selected == 'selected')
					pimpas.DOM.setObjectValue( id, value );
			}
	   }
   }
);